﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DCS.DataProvider;
using DCS.Business.Model;

namespace DCS.Business.Manager
{
    public class SITAMessageManager
    {
        private IDataProvider _provider;

        //private OledbDataProvider _oledbProvider;

        public SITAMessageManager(IDataProvider provider)
        {
          this._provider=provider;
          //_oledbProvider = new OledbDataProvider();
        }

        #region SourceMessage 
        public List<SITAMessage> GetNewMessageList(int MaxID,string monthDir,string sqlName)
        {
            return OledbDataProvider.GetNewMessageList(MaxID, monthDir, sqlName);
        }

        public List<SITAMessage> GetSourceMessageToParse(string messageType, int rowSize, int selectStatus, int updateStatus)
        {
            return _provider.GetSourceMessageToParse(messageType, rowSize, selectStatus, updateStatus);
        }

        public int GetMaxSourceID(string monthDir)
        {
            return _provider.GetMaxSourceID(monthDir);
        }

        public int InsertSourceMessageModel(SITAMessage model)
        {
            model.DownLoadTime = DateTime.Now;
            return _provider.InsertSourceMessage(model);
        }

        public void UpdateSourceMessageModel(SITAMessage model)
        {
             _provider.UpdateSourceMessage(model);
        }

        public void UpdateSourceMessageModelList(List<SITAMessage> modelList)
        {
            foreach (SITAMessage model in modelList)
            {
                UpdateSourceMessageModel(model);
            }
        }

        public void InsertSourceMessageList(List<SITAMessage> messgaeList)
        {
            if (messgaeList == null)
            {
                return;
            }
            foreach (SITAMessage message in messgaeList)
            {
                InsertSourceMessageModel(message);
            }

        }

        public TRChangeMessage InsertTRChangeMessage(TRChangeMessage TRChangeMessage)
        {
            return _provider.InsertTRChangeMessage(TRChangeMessage);
        }

        public ACChangeMessage InsertACChangeMessage(ACChangeMessage ACChangeMessage)
        {
            return _provider.InsertACChangeMessage(ACChangeMessage);
        }

        public CancleMessage InsertCancleMessage(CancleMessage cancleMessage)
        {
            return _provider.InsertCancleMessage(cancleMessage);
        }

        public void InsertCancleMessageList(List<CancleMessage> list)
        {
            foreach (CancleMessage message in list)
            {
                InsertCancleMessage(message);
            }
        }
        
        public void InsertACChangeMessageList(List<ACChangeMessage> list)
        {
            foreach (ACChangeMessage message in list)
            {
                InsertACChangeMessage(message);
            }
        }

        public void InsertTRChangeMessageList(List<TRChangeMessage> list)
        {
            foreach (TRChangeMessage message in list)
            {
                InsertTRChangeMessage(message);
            }
        }

        public void UpdateSourceMessageStatus(List<int> idList, FileStatus status)
        {
            _provider.UpdateSourceMessageStatus(idList, status);
        }


        #endregion


    }
}
